<%@ page language="java" pageEncoding="utf8"%>
<%
String movieIdStr = request.getParameter("movieID");
Integer movieId = null;
if(movieIdStr == null) {
	movieId = (Integer)session.getAttribute("movieID");
}
else {
	movieId = new Integer(movieIdStr);
}
 %>
<jsp:include page="/head_admin.jsp" />
<script type="text/javascript" src="script/movieSession.js"></script>
<script type="text/javascript">
	dojo.require("dijit.form.DateTextBox");
	
   	dojo.addOnLoad(function(){
   		MovieSession.movieId =<%=movieId%>;
   		MovieSession.action = "manage";
  		MovieSession.askForMovieBriefInfo();
  		MovieSession.askForMovieSessionInfo();
  		dijit.byId("sessionGrid").resize();
  		//alert("场次添加成功");
   	});
   	
   	var manageAllSessions = {
       	items:[]
    };
	
	var hallNameData = {
		identifier:"id_seat",
    	items:[]
    };
   
    var hallNameStore = new dojo.data.ItemFileWriteStore({
    	data:hallNameData
    });
    
	var manageSessionStore = new dojo.data.ItemFileWriteStore({data:manageAllSessions});
	
	function editSession(sessionId) {
		MovieSession.init();
		document.getElementById("sessionId").value=sessionId;
		dijit.byId("editSessionDlg").show();
	}
	
	function deleteSession(sessionId) {
		if(confirm("确认删除该场次？")==true) {
			var href = "deleteSession.do?sessionId="+sessionId;
			ajaxRequest(href, updateSesStore, null);
		}
	}
	
	function updateSesStore(ajax_request) {
		var item = dijit.byId("sessionGrid").removeSelectedRows();
		manageSessionStore.deleteItem(item);
	}
	
	function addMovieSession() {
		document.location.href = "addMovieSession.jsp?movieID="+MovieSession.movieId;
	}
   	
</script>
<style type="text/css">
	#sessionGrid{
		width:98%;
	}
	.dojoxGrid table {
        margin: 0;
        font-size: 12px;
        text-align: center;
    }
</style>
<div class="maincontent">
	<div class="HackBox"></div>
	<div id="breadcrumb">
		&nbsp;
		<a href="index.jsp">主页</a>&nbsp;&gt;&nbsp;
		<a href="movieManage.jsp">电影管理</a>&nbsp;&gt;&nbsp;电影场次管理
	</div>

	<div class="maincontentin">
		<div class="addBook_div">
			<span class="addBook_bar"> <span class="left"></span> <span
				class="addMovie_icon">&nbsp;电影场次管理&nbsp;</span></span>
			<form id="addMovieForm" name="addMovieForm" action="addMovieSession.do" method="post" >
				<table class="addBookTable">
					<tr>
						<td width="10%">
							<img src="" id="mrPhoto" style="padding:10px"></img>
						</td>
						<td>
							<ul class="movieBriefInfo">
								<li style="font-size: 14px; color: red;"><span id="mrName"></span></li>
 								<li>语言：<span id="mrLanguage"></span></li>
 								<li>时长：<span id="mrTime"></span></li>
							</ul>
						</td>
						<td width="50%">
							<span class="blue-btn"> <span class="inputbtn">
							<span class="l"></span> <input type="button" value='添加电影场次' onclick="addMovieSession()"></input>
						</td>
					</tr>
					<tr>
						<td colspan="3">
							<hr class="dotline"></hr>
						</td>
					</tr>
					<tr>
						<td colspan="3">
							<div id="adminGridDiv">
								<table dojoType="dojox.grid.DataGrid" id="sessionGrid" selectionMode="single"
								 style="background:#E9F6FD none repeat scroll 0 0; padding-left:10px" autoHeight="true" store="manageSessionStore">
									<thead>
										<tr>
											<th field="rowId" hidden="true"></th>
											<th field="sessionName" width="30%">放映场次</th>
											<th field="hallName" width="20%">放映厅</th>
											<th field="price" width="10%">票价</th>
											<th field="editSes" width="20%">编辑</th>
									 		<th field="deleteSes" width="20%">删除</th>
										</tr>
									</thead>
								</table>
							</div>
						</td>
					</tr>
				</table>
			</form>
		</div>
	</div>

</div>
<div id="editSessionDlg"
	style="display: none;width:60%; height: 220px;"
	dojoType="dijit.Dialog" title='编辑电影场次' class="pop-window">
	<form action="addMovieSession.do?action=update" method="post">
		<table>
				<tr>
					<td class="label" style="width:13%; padding:5 0"><span style="color:red">*</span>播放日期： 
					</td>
					<td style="width:45%">
						<input type="text" name="sesDate" id="sesDate"
							dojoType="dijit.form.DateTextBox"
							constraints="{datePattern:'yyyy-MM-dd'}" required="true"
							invalidMessage="请输入播放日期" />
					</td>
					<td style="padding-left:40px">更新播放日期，格式(2008-01-12)</td>
				</tr>
				<tr>
					<td class="label" style="padding:5 0"><span style="color:red">*</span>播放时间：
					</td>
					<td>
						<input dojoType="dijit.form.ValidationTextBox" id="sesTime"
							name='sesTime' required="true" invalidMessage="请输入播放时间" />
					</td>
					<td style="padding-left:40px">更新播放时间，格式10:30(24小时制)</td>
				</tr>
				<tr>
					<td class="label" style="padding:5 0"><span style="color:red">*</span>放映厅：
					</td>
					<td>
						<select id="hallContainer" name="hallContainer"
							style="" dojoType="dijit.form.ComboBox" 
							store="hallNameStore" onchange="MovieSession.setHallNote()">
					</td>
					<td style="padding-left:40px">
						<span  id="hallNote"></span>
						<input type="hidden" id="hallId" name="hallId" value="0">
						<input type="hidden" id="movieId" name="movieId" value="0">
						<input type="hidden" id="sessionId" name="sessionId" value="0">
					</td>
				</tr>
				<tr>
					<td class="label" style="padding:5 0"><span style="color:red">*</span>价格：
					</td>
					<td>
						<input dojoType="dijit.form.ValidationTextBox" id="price"
							name="price" required="true" invalidMessage="请输入影片价格" />（元） 
					</td>
					<td style="padding-left:40px">更新影片价格</td>
				</tr>
				<tr>
					<td colspan="3">
						<div class="buttonbar">
							<div class="btngroup">
								<span class="blue-btn"> <span class="inputbtn"> <span
										class="l"></span> <input type="submit" value='保存'></input> </span> </span>
							</div>
						</div>
					</td>
				</tr>
		</table>
	</form>
</div>
<!-- main content -->


<jsp:include page="footer.jsp" />